<template>
    <div class="cateOne">
        <h1>-{{title}}-<span>产看全部&gt;</span></h1>
        <h2>{{desc}}</h2>
        <ul>
            <li v-for="item in cateOneList" :key="item.id">
                <img :src="item.picture" alt="">
                <p>{{ item.name }}</p>
                <p style="color:#ccc;">{{ item.desc }}</p>
                <p style="text-align:center;">
                    <span style="color:red;">￥{{ item.price }}</span>
                </p>
            </li>
        </ul>
    </div>
</template>

<script>
import { getCateApi } from '@/utils/api/categoryapi'
export default {
    props: ['nowId'],
    data() {
        return {
            cateOneList: [],
            title:'',
            desc:'',
        }
    },
    methods: {
        async getCateList() {
            let res = await getCateApi(this.nowId);
            // console.log(res);
            this.cateOneList = res.result.children[1].goods;
            this.title = res.result.children[1].name;
            this.desc = res.result.children[1].goods[1].desc;
            // console.log(this.cateOneList);
        }
    },
    mounted() {

    },
    watch: {
        nowId(val) {
            if (val) {
                this.getCateList();
            }
        }
    }
}
</script>

<style lang="scss" scoped>
@import '@/assets/css/components';
.cateOne {
    width: 100%;
    height: 500px;
    background-color: white;
    margin-top: 20px;

    h1 {
        width: 100%;
        height: 80px;
        text-align: center;
        line-height: 120px;
        position: relative;

        span {
            font-size: 20px;
            color: rgb(141, 138, 138);
            position: absolute;
            top: -20px;
            right: 10px;
        }
    }

    h2 {
        text-align: center;
        margin-bottom: 40px;
    }

    ul {
        width: 80%;
        height: 280px;
        // background-color: red;
        margin: 0 auto;
        display: flex;
        justify-content: space-between;

        li {
            width: 17%;
            height: 100%;
            // background-color: greenyellow;
            @include hoverShadow();
            img {
                width: 100%;
                height: 60%;
            }
            p {
                font-size: 20px;
                overflow: hidden; //（文字长度超出限定宽度，则隐藏超出的内容）
                white-space: nowrap; //（设置文字在一行显示，不能换行）
                text-overflow: ellipsis; //（规定当文本溢出时，显示省略符号来代表被修剪的文本）
            }
        }
    }
}
</style>